package com.treeroot.treenet.protocol.abs.tcp.route;

import com.treeroot.treenet.protocol.abs.tcp.session.TcpSession;
import com.treeroot.treenet.protocol.abs.tcp.decode.DecodedMessage;

import java.io.IOException;

/**
 * Description: 消息路由器
 * Create By TreeRoot
 * Create Time: 2025/06/02 10:19
 * Class Name: MessageRouter
 *
 * @author TreeRoot
 */
public interface MessageRouter {
    /**
     * 注册handler
     *
     * @param messageType 消息类型
     * @param handler     操作者
     */
    void registerHandler(String messageType, RouteHandler handler);

    /**
     * 路由
     *
     * @param message 消息
     * @param session session
     * @throws IOException IOException
     */
    void route(DecodedMessage message, TcpSession session) throws IOException;
}